<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户登录</title>
    <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.5.1.min.js"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f4f4f4;
            margin: 0;
            padding: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
        }
        .container {
            background-color: #fff;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
            width: 300px;
        }
        h3 {
            color: #333;
            text-align: center;
            margin-bottom: 20px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            color: #555;
        }
        input[type="text"] {
            width: 100%;
            padding: 10px;
            margin-bottom: 15px;
            border: 1px solid #ddd;
            border-radius: 4px;
            box-sizing: border-box;
        }
        button {
            width: 100%;
            padding: 10px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 16px;
        }
        button:hover {
            background-color: #45a049;
        }
    </style>
</head>
<body>
<div class="container">
    <h3>获取OTP信息</h3>
    <div>
        <label>手机号</label>
        <div>
            <input type="text" placeholder="手机号" name="teiphone" id="teiphone">
        </div>
    </div>
    <div>
        <button id="getotp" type="button">
            获取OTP短信
        </button>
    </div>
</div>
</body>
<script>
    jQuery(document).ready(function(){
       $("#getotp").on("click",function(){
       var teiphone=$("#teiphone").val();
       if(teiphone==null||teiphone==""){
       alert("手机号不能为空")
       return false;
       }
          $.ajax({
          type:"POST",
          contentType:"application/x-www-form-urlencoded",
          url:"http://localhost:8090/user/getotp",
          data:{
          "teiphone":$("#teiphone").val()
          },
        xhrFields: {
        withCredentials: true
    },
          success:function(data){
          if(data.status=="success"){
          alert("otp已经发送到您的手机上，注意查收")
          window.location.href="/miaoshaoqiangduan/register.html";
          }else{
          alert("otp发送失败，原因为"+data.data.errMsg)
          }
          },
          error:function(data){
          alert("otp发送失败，原因为"+data.responseText);
          }
          });
          return false;
        });
    });
</script>
</html>